package day04;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Scanner;

import org.junit.Test;

/**
 * 要求用户输入若干员工信息，格式为：
 * name,age,gender,salary,hiredate;name,age,gender,salary,hiredate;....
 * 例如:
 * 张三,25,男,5000,2006-02-15;李四,26,女,6000,2007-12-24;...
 * 然后将每个员工信息解析成Emp对象。并存入到一个集合中。
 * 然后循环集合，输出每一个员工信息(输出使用toString返回的字符串)
 * 然后输出每个员工的转正仪式日期。
 * 转正仪式日期为:入职3个月的当周周五
 * 
 * @author Bonnie
 *
 */
public class Test09 {
	@Test
	public void test() throws ParseException {
		Scanner console = new Scanner(System.in);
		System.out.println("请输入员工信息：");
		String message = console.nextLine();
		String[] perInfo = message.split("[;]{1}");
		List<Emp> list = new ArrayList<Emp>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		for (String obj : perInfo) {
			String[] data = obj.split("[,]{1}");
			String name = data[0];
			int age = Integer.parseInt(data[1]);
			String gender = data[2];
			int salary = Integer.parseInt(data[3]);
			Date date = sdf.parse(data[4]);
			Emp stuff = new Emp(name, age, gender, salary, date);
			list.add(stuff);
		}
		for (Emp obj : list) {
			System.out.println(obj);
		}
		for (Emp obj : list) {
			Calendar cal = Calendar.getInstance();
			cal.setTime(obj.getHiredate());
			cal.add(Calendar.MONTH, 3);
			cal.set(Calendar.DAY_OF_WEEK, 6);
			System.out.println(obj.getName() + "：" + sdf.format(cal.getTime()));
		}
		
		
		console.close();
	}
	
}
